package me.sdevil507.biz.fruit.po;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import me.sdevil507.supports.jpa.BaseJpaSnowflakeIdEntity;
import me.sdevil507.supports.upload.po.AttachFile;
import org.hibernate.annotations.Formula;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @program: tips_back_end
 * @description: 感谢和证明信
 * @author: kzl
 * @create: 2020-07-22 16:29
 **/
@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "biz_fruit_prove")
public class FruitProvePO extends BaseJpaSnowflakeIdEntity {



    /**
     * 成果id
     */
    @Column
    private Long  fruitId;

    /**感觉或者类型类型
     * 1.报送证明
     * 2.采用证明
     * 3.收录证明
     * 4.感谢信
     * 5.其他证明
     * **/
    @Column
    private String type;

    /**发放单位**/
    @Column
    private String grantUnit;


    /**发放单位级别**/
    @Column
    private String level;

    @Formula("(select t.d_name from biz_sysdict as t  where t.d_value=level and t.type_key='InclinationsLevel')")
    private String levelName;
    /**发放时间**/
    @Column
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date grantDate;

    /**相关批示附件**/
    @OneToMany(targetEntity = AttachFile.class, cascade= CascadeType.MERGE, orphanRemoval = true)
    @JoinColumn(name="relationId")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<AttachFile> attFiles =new ArrayList<>();

    /**
     * 创建时间
     */
    @Column
    private Date createTime = new Date();

    /**
     * 更新时间
     */
    @Column
    private Date updateTime = new Date();

    /**
     * 智库id
     */
    @Column
    private Long orgId;

    /**
     * 平台操作用户id
     */
    @Column
    private Long userId;

    /**
     * 平台操作用户姓名
     */
    @Column
    private String userName;

}
